When you initialize a git project, all work by default is done on the
master branch. When
you make your first commit, the
master branch is automatically created.
Note: You can have the
master branch be
git branch -M main after the first commit.
You can create new branches from the
master branch when you develop new features in your project
or when you do testing. You can also see which branch you're on by using the
git branch command.
# Here's an example of the Phaktionz-CLI branches $ git branch * beta edge main stable # As can be seen, the master branch is switched to main # and the current branch being worked on is the beta branch.
In Git, the
git branch branch_name command is used to create a new branch called
Branches should be named something that describes the purpose of the branch.
For example: The
beta branch represents the beta channel of Phaktionz-CLI.
Also a branch name cannot contain white spaces:
some-name are valid,
some name is invalid.
In Git, you can delete a branch by using
git branch -d branch_name, and then the branch
branch_name will be removed.
Note: Usually it's a good idea to merge the branch with the
master branch before deleting.
In Git, if you would like to merge a branch with another, use the
git merge command.
When you use the command
git merge branch_name, it will merge the branch,
the branch you're currently on.
This is useful when your new feature works, so you can merge all the changes in that branch